package naive2;

import org.json.JSONException;
import org.json.JSONObject;

import entities.Entity;

public class JsonEntity {
	private Entity entity;
	private JSONObject jobj;
	private JsonEntity(Entity entity, JSONObject jobj){
		this.entity = entity;
		this.jobj = jobj;
	}
	public JSONObject getJobj() {
		return jobj;
	}
	public boolean hasJSON(){
		
		if (this.jobj != null)
			return true;
		else
			return false;
	}
	public Entity getEntity(){
		return this.entity;
	}
	
	public String getType(){
		try {
			return jobj.getString("type");
		} catch (JSONException e) {
			// TODO Auto-generated catch block
			//e.printStackTrace();
			return "None";
		}
	}
	
	public static JsonEntity instance(Entity entity, LuceneJsonRetriever lj) throws JSONException{
		
		return new JsonEntity(entity,lj.getJSONObj(entity.getName()));
	
	
	}
	
	
	
}
